package com.atnjupt.regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Wizarder
 * @create 2022-03-23 11:58
 * 匹配url地址
 */
public class RegDemo1 {

    public static void main(String[] args) {
//        String context = "https://www.bilibili.com/video/BV1Eq4y1E-79W?p=18&spm_id_from=pageDriver";
        String context = "http://edu.3dsmax.tech/yg/bilibili/my6652/pc/qg/05-51/index.html#201211-1?track_id=jMc0jn-hm-yHrNfVad37YdhOUh41XYmjlss9zocM26gspY5ArwWuxb4wYWpmh2Q7GzR7doU0wLkViEhUlO1qNtukyAgake2jG1bTd23lR57XzV83E9bAXWkStcAh4j9Dz7a87ThGlqgdCZ2zpQy33a0SVNMfmJLSNnDzJ71TU68Rc-3PKE7VA3kYzjk4RrKU";
        String regx = "^((http|https)://)?([\\w-]+\\.)+[\\w-]+(\\/[\\w-.?&#=%]*)*$";
//        String regx = "(^(http|https)://)?([\\w-]+\\.)+[\\w-]+(\\/[\\w-?=&/%.#]*)?$";
        Pattern compile = Pattern.compile(regx);
        Matcher matcher = compile.matcher(context);
        if (matcher.find()) {
            System.out.println("满足匹配要求");
        } else {
            System.out.println("不满足匹配要求");
        }
    }
}
